package cn.school.course.vo;

import cn.school.common.utils.CourseUtils;
import cn.school.common.utils.WeekVo;
import cn.school.course.entity.Course;
import cn.school.course.entity.CourseSessions;
import cn.school.sys.entity.TermTime;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 班级课表对象
 *
 * @className: WeekCourseTableBySchoolClass
 * @author: fangjin.tao
 * @date: 2023/2/1
 **/
@Data
public class WeekCourseTableBySchoolClassRspVo {
	private List<CourseTableRow> CourseTableRow = new ArrayList();
	private List<Map> columnTitles = null;
	/** 班级id */
	private String scclId;
	/** 学年学期 */
	private TermTime termTime;
	/** 当前周次 */
	private WeekVo weekVo;
	
	
	public WeekCourseTableBySchoolClassRspVo(WeekCourseTableBySchoolClassReqVo reqVo, List<CourseSessions> courseSessionsList, List<Course> courseList) {
		columnTitles = CourseUtils.gennerClumnTites(reqVo.getCourBeginAreaTime(), reqVo.getCourEndAreaTime());
		Map<Long, List<Course>> courseSessionMap = new HashMap<>();
		if (courseList != null && courseList.size() != 0) {
			courseSessionMap = courseList.stream().collect(Collectors.groupingBy(Course::getCoseId));
		}
		for (CourseSessions courseSessions : courseSessionsList) {
			List<Course> tempCourseList = courseSessionMap.get(courseSessions.getId());
			CourseTableRow courseTableRow = new CourseTableRow(courseSessions, tempCourseList);
			CourseTableRow.add(courseTableRow);
		}
	}
}
